package character;

import Sorts.Books;
import Sorts.ComicBooks;
import Sorts.Novels;
import Sorts.ProgrammingBooks;

public class Main {
    public static void main(String[] args) {
        theSystem system = new theSystem();
        system.AdminLogin();
//        创建书
        Books newBook1 =new ComicBooks("aaa",100,1,1,"zuozhe1","jianjie1");//漫画书aaa
        Books newBook2 =new Novels("bbb",150,0,0,"zuozhe2","jianjie2","zhujue");//小说bbb
        Books newBook3 =new ComicBooks("ccc",100,1,1,"zuozhe3","jianjie3");//漫画ccc
        Books newBook4 =new ProgrammingBooks("ddd",1000,2,2,"java","blog4");//编程书ddd
        Books newBook5 =new Novels("eee",200,0,0,"zuozhe5","jianjie5","zhujue5");
        system.createBook(newBook1);
        system.createBook(newBook2);
        system.createBook(newBook3);
        system.createBook(newBook4);
        system.createBook(newBook5);

//创建书架
        system.createBookSelf();
        system.createBookSelf();
        system.createBookSelf();

        //把书放到书架上
        system.addBookToBookSelf(newBook1,0);
        system.addBookToBookSelf(newBook2,0);
        system.addBookToBookSelf(newBook3,1);
        system.addBookToBookSelf(newBook4,2);
        system.addBookToBookSelf(newBook5,2);

        system.AdminLogout();
//用户a行为
        system.UserZhuCe("a","xuejavarangrenzibi");
        system.UserLogin("a","xuejavarangrenzibi");
        system.borrowBook("aaa");
        system.borrowBook("bbb");
        system.borrowBook("eee");
        system.UserLogout();

//用户b行为
        system.UserZhuCe("b","xuebuhuijava");
        system.UserLogin("b","xuebuhuijava");
        system.borrowBook(null);
        system.borrowBook("ddd");
        system.UserLogout();

//把b设成黑名单
        system.AdminLogin();
        system.setUserBlack("b","xuebuhuijava");

//书架输出

        for (int i = 0; i < system.getshujiashuliang(); i++) {
            System.out.println("第" + (i + 1) + "个书架：");
            for (Books book : system.zhaoshu(i)) {
                System.out.println(book.toString());
            }
        }
        System.out.println();
//用户a输出
        for (Users user : system.allusers()) {
            if (user.getUsername().equals("a")) {
                System.out.println("a的所有书：");
                for (Books book : user.getMyBooks()) {
                    System.out.println(book.toString());
                }

                System.out.println("a的小说有：");
                for (Books book : user.getA_kindofBook(0)) {
                    System.out.println(book.toString());
                }
            }
//用户b输出
            else if (user.getUsername().equals("b")) {
                System.out.println("b的所有书：");
                for (Books book : user.getMyBooks()) {
                    System.out.println(book.toString());
                }
            }
        }
        system.AdminLogout();

    }
}
